<template>
    <view class="snowy-form">
        <uni-forms ref="formRef" :model="formData" label-position="top" :rules="rules" validate-trigger="blur" labelWidth="auto">
            <uni-forms-item label="姓名" name="xm" :required="false" :rules="[{ required: false, errorMessage: '请输入姓名' }]">
            	<uni-easyinput v-model="formData.xm" placeholder="请输入姓名"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="曾用名" name="cym" :required="false" :rules="[{ required: false, errorMessage: '请输入曾用名' }]">
            	<uni-easyinput v-model="formData.cym" placeholder="请输入曾用名"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="性别" name="xb" :required="false" :rules="[{ required: false, errorMessage: '请输入性别' }]">
            	<uni-easyinput v-model="formData.xb" placeholder="请输入性别"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="性别代码" name="xbdm" :required="false" :rules="[{ required: false, errorMessage: '请输入性别代码' }]">
            	<uni-easyinput v-model="formData.xbdm" placeholder="请输入性别代码"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="出生日期" name="csrq" :required="false" :rules="[{ required: false, errorMessage: '请输入出生日期' }]">
            	<uni-easyinput v-model="formData.csrq" placeholder="请输入出生日期"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="民族" name="mz" :required="false" :rules="[{ required: false, errorMessage: '请输入民族' }]">
            	<uni-easyinput v-model="formData.mz" placeholder="请输入民族"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="民族代码" name="mzdm" :required="false" :rules="[{ required: false, errorMessage: '请输入民族代码' }]">
            	<uni-easyinput v-model="formData.mzdm" placeholder="请输入民族代码"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="身份类型" name="sfzjlxm" :required="false" :rules="[{ required: false, errorMessage: '请输入身份类型' }]">
            	<uni-easyinput v-model="formData.sfzjlxm" placeholder="请输入身份类型"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="证件号码" name="sfzjh" :required="false" :rules="[{ required: false, errorMessage: '请输入证件号码' }]">
            	<uni-easyinput v-model="formData.sfzjh" placeholder="请输入证件号码"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="教工类型名称" name="jzglbmc" :required="false" :rules="[{ required: false, errorMessage: '请输入教工类型名称' }]">
            	<uni-easyinput v-model="formData.jzglbmc" placeholder="请输入教工类型名称"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="教工类别代码" name="jzglbdm" :required="false" :rules="[{ required: false, errorMessage: '请输入教工类别代码' }]">
            	<uni-easyinput v-model="formData.jzglbdm" placeholder="请输入教工类别代码"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="教师职称" name="jszc" :required="false" :rules="[{ required: false, errorMessage: '请输入教师职称' }]">
            	<uni-easyinput v-model="formData.jszc" placeholder="请输入教师职称"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="教师职称代码" name="jszcdm" :required="false" :rules="[{ required: false, errorMessage: '请输入教师职称代码' }]">
            	<uni-easyinput v-model="formData.jszcdm" placeholder="请输入教师职称代码"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="当前状态" name="dqzt" :required="false" :rules="[{ required: false, errorMessage: '请输入当前状态' }]">
            	<uni-easyinput v-model="formData.dqzt" placeholder="请输入当前状态"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="状态代码" name="dqztdm" :required="false" :rules="[{ required: false, errorMessage: '请输入状态代码' }]">
            	<uni-easyinput v-model="formData.dqztdm" placeholder="请输入状态代码"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="所属单位名称" name="dwmc" :required="false" :rules="[{ required: false, errorMessage: '请输入所属单位名称' }]">
            	<uni-easyinput v-model="formData.dwmc" placeholder="请输入所属单位名称"></uni-easyinput>
            </uni-forms-item>
            <uni-forms-item label="单位代码" name="dwh" :required="false" :rules="[{ required: false, errorMessage: '请输入单位代码' }]">
            	<uni-easyinput v-model="formData.dwh" placeholder="请输入单位代码"></uni-easyinput>
            </uni-forms-item>
        </uni-forms>
        <tui-button margin="50rpx 0" :preventClick="true" :shadow="true" @click="submit">提交</tui-button>
    </view>
</template>

<script setup name="jwJzgxxForm">
    import { onLoad } from "@dcloudio/uni-app"
    import jwJzgxxApi from '@/api/biz/jw-jzgxx-api'
    import { reactive, ref, getCurrentInstance } from "vue"
    import CallbackState from "@/enum/callback-state"

    const { proxy } = getCurrentInstance()
    const formRef = ref()
    const formData = ref({})
    // 常用正则规则大全：https://any86.github.io/any-rule/
    // 去pages/biz/user/form.vue中寻找示例
    const rules = reactive({
    })
    onLoad((option) => {
        if(!option.id){
            return
        }
        jwJzgxxApi.jwJzgxxDetail({
            id: option.id
        }).then(data => {
            formData.value = data
        })
    })
    const submit = () => {
        formRef.value.validate().then(res => {
            jwJzgxxApi.jwJzgxxSubmitForm(formData.value, !formData.value.id).then(data => {
                uni.$emit('formBack', {
                    data: data
                })
                uni.navigateBack({
                    delta: 1
                })
            })
        })
    }
</script>
<style lang="scss" scoped>
</style>
